package com.usian.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.usian.mapper.ApBehaviorEntryMapper;
import com.usian.model.behavior.pojos.ApBehaviorEntry;
import com.usian.service.ApBehariorEntryService;
import org.springframework.stereotype.Service;

@Service
public class ApBehariorEntryServiceImpl extends ServiceImpl<ApBehaviorEntryMapper, com.usian.model.behavior.pojos.ApBehaviorEntry> implements ApBehariorEntryService {


    @Override
    public ApBehaviorEntry findEntryId(Integer userId, Integer equipmentId) {
        //根据账号或者设备 查询行为实体表中主键id  对象
        ApBehaviorEntry behaviorEntry =new ApBehaviorEntry();
        if(userId!=null){
            behaviorEntry = this.getOne(Wrappers.<ApBehaviorEntry>lambdaQuery()
                    .eq(ApBehaviorEntry::getType, 1).eq(ApBehaviorEntry::getEntryId, userId));
        }else if(userId==null && equipmentId!=null){
            behaviorEntry = this.getOne(Wrappers.<ApBehaviorEntry>lambdaQuery()
                    .eq(ApBehaviorEntry::getType, 0).eq(ApBehaviorEntry::getEntryId, equipmentId));
        }
        return behaviorEntry;
    }
}
